How did we port Trojan to Windows?
-----------------------------------------------------------------

Well, there are lots of issues at stake here, mostly because
Trojan was a double port: from M1 -> M2 on the Mac and then
from MacM2 -> WinM2.


M1 -> M2
--------

The M1->M2 conversion was problematic simply because of the
differences between the two games - monsters trigger and act
differently, liquids act and do damage differently. Any level
that relied on monsters and liquids for all/part of the challenge
needed some re-working. Textures and lighting don't come across
too well, and so need to be redone/checked by hand.

Furthermore, Forge gets a lot of things wrong when it converts
an M1 level - it chooses really dumb polygon types for the M1
types that cannot be supported in M2 (glue, superglue, damage,
major damage), and (worse almost) fails to correctly convert
monsters into slots that show up on the map/motion sensor
in the way you'd expect.

Luckily, MikeT was able to write a couple of Chisel effects that
swapped polygon and monster types about to make this less
tedious.

We sadly had to drop the specially composed music that played in
each level as the M2 engine won't play MIDI. We are hoping to
add code to the Aleph-1 project to return MIDI playback to
Marathon in the future.

The final problem with Trojan was that it is a total conversion:
the only file it uses from the original game is the engine and
even that has been modified.

HAS was able to make an M2 compatible shapes file from the M1
artwork, and also succeeded in copying a lot of the sounds
across, but not, unfortunately, the MIDI based music that
was specially composed for each level. This is a sad loss.
He also created a physics file that mimiced the M1 monster
and liquid behaviours as closely as possible.

FUX made it simple to alter the game's inbuilt physics to match
these settings, making it impossible to accidentally revert
to M2 settings, and also made making the changes to the rest
of the interface child's play.

So - we had a working and tested M2 version. How do we then
take that onto the PC?


M2mac -> M2win
--------------

Bungie's Portmaster made actually getting M2win format files
pretty easy, but that was by no means the end of it. In fact,
this was just the start.

M2.exe is, basically, a nasty hack. Sorry, but 'tis true. It
was built to play the 'Marathon 2 - Durandal' scenario and
little else. Many, many things are hard coded that in the
Mac version are simple to change: if you want sounds to play
with your chapter screens, you'd better only have the same
number as Durandal had, and (unless you hack the .exe) they'll
only play after the level numbers that chapter screens were
shown at in the original game.

Worse than that, other bits of the game are pretty broken.

Terminals in M2.exe are seriously deficient:
  #INFORMATION is totally broken - it insets the rectangle
   that is flows text into the _wrong way_, and so it goes
   off the screen, clipping both ends of every line.
  #PICT will only show the first screen of any attached
   text (the rest just goes into the bit bucket), and gets
   all the line lengths wrong unless you use the magic
   Arial font to work out where to break the lines yourself
  #LOGON only stays on the screen for a split second, so
   there is no way you can read it.

Sounds only work and mix properly if they are at exactly
the right sampling rate and bit depth. M2mac used Quicktime
to do its sounds and so was much more flexible.

You can't use fonts as flexibly as on the Mac - all the
fonts and sizes that the Mac version stores in an easily
editable resource are hard coded into the .exe file.

Lastly, there is no FUX for windows. Changing the .exe
means digging out your hex editor. Since MikeT learnt to
make changes to the Mac game using a hex editor this was
not so much of a problem, but you will have to have
some idea of what you are doing. We took the original
Mac M2 and compared it byte for byte with our modified
Trojan M2 so we could get a list of changes.

Ok - so you can take this list and then search the PC
.exe file for the same numbers and change them? Almost.
Unfortunately the Mac and the PC store numbers differently.
While the Mac might store the value 258 as 01 02 or
00 00 01 02, the PC will store it as 02 01 or 02 01 00 00

In other words you need to know how much space a particular
number occupies in order to work out how to swap it properly.
You'll need to look at, and understand, the header files that
Bungie made available as Open Source recently. The same
structures are used on both platforms and the data in any 
file except for the .exe is in exactly the same order.

Text in the .exe is stored as Unicode - convert from ASCII
by interspacing extra bytes set to zero. This can make
searching for text interesting unless you know ASCII codes
by heart. (what sort of geek are you if you don't, right?)

As long as you don't change the length of a text string
things will be easy. Although each string has a length
byte in front (like a Pascal string), changing these will
work in some cases and not in others. It isn't reliable.


Finally - don't give up. It isn't impossible. Look at
Trojan and look at Wheels - we've done it twice :)



Mike Trinder
17/04/00